#!/bin/ash -efu

cmdline_get_CMDLINE='ro rw= root=LABEL=ROOT resume=/dev/sda1 panic=30 foo.bar="zzz xxx" BOOT_IMAGE=/bad/param BOOT-IMAGE=/boot/vmlinuz'

cmdline_get_test1() { # UnitTest
	. ../shell-cmdline

	local result
	cmdline_get 'result' 'resume' "$cmdline_get_CMDLINE"
	assertEquals "resume=[$result]" "$result" '/dev/sda1'
}

cmdline_get_test2() { # UnitTest
	. ../shell-cmdline

	local result
	cmdline_get 'result' 'ro' "$cmdline_get_CMDLINE"
	assertEquals "ro=[$result]" "$result" '1'
}

cmdline_get_test3() { # UnitTest
	. ../shell-cmdline

	local result
	cmdline_get 'result' 'rw' "$cmdline_get_CMDLINE"
	assertEquals "rw=[$result]" "$result" ''
}

cmdline_get_test4() { # UnitTest
	. ../shell-cmdline

	local result
	cmdline_get 'result' 'root' "$cmdline_get_CMDLINE"
	assertEquals "root=[$result]" "$result" 'LABEL=ROOT'
}

cmdline_get_test5() { # UnitTest
	. ../shell-cmdline

	local result
	cmdline_get 'result' 'foo.bar' "$cmdline_get_CMDLINE"
	assertEquals "foo.bar=[$result]" "$result" 'zzz xxx'
}

cmdline_get_test6() { # UnitTest
	. ../shell-cmdline

	local result
	cmdline_get 'result' 'BOOT-IMAGE' "$cmdline_get_CMDLINE"
	assertEquals "BOOT-IMAGE=[$result]" "$result" '/boot/vmlinuz'
}

cmdline_get_test7() { # UnitTest
	. ../shell-cmdline

	local result
	cmdline_get 'result' 'BOOT_IMAGE' "$cmdline_get_CMDLINE"
	assertEquals "BOOT_IMAGE=[$result]" "$result" '/boot/vmlinuz'
}
